<template>
	<div class="mui-numbox">
	  <!-- "-"按钮，点击可减小当前数值 -->
	  <button class="mui-btn mui-numbox-btn-minus" type="button">-</button>
	  <input class="mui-numbox-input" type="number" @change="countChanged" ref="numbox"/>
	  <!-- "+"按钮，点击可增大当前数值 -->
	  <button class="mui-btn mui-numbox-btn-plus" type="button">+</button>
	</div>
</template>

<script>
 import mui from "../../lib/mui/js/mui.min.js";
 export default {
 	 mounted() {
 	   mui(".mui-numbox").numbox();
 	 },
 	 methods:{
 	 	countChanged(){
	 	 	this.$emit("getcount",parseInt(this.$refs.numbox.value));
	 	 	console.log(this.$refs.numbox.value);
	 	 }
 	 },
 	  props: ["max"],
	  watch: {
	    // 属性监听
	    max: function(newVal, oldVal) {
	      // 使用 JS API 设置 numbox 的最大值
	      mui(".mui-numbox").numbox().setOption("max", newVal);
	    }
	  }
 	 
 }
</script>

<style>
</style>